const { post } = require("./fetch.js")
const { contractId } = require("./contractId.js")

async function createContract(data) {
  try {
    const response = await post('/api/helloris/contract/payment/create', data);
    console.log(response.data);
  } catch (error) {
    console.error('请求失败:', error);
  }
}

// 调用函数
const postData = {
    "contractId": contractId,
    "paymentDate": "2024-03-02",
    "paymentAmount": 20,
    "useOffline": true,
    "useAccount": false,
    "unreceivedAmount": 20,
    "studentAccountAmount": 0,
    "receipts": [
        {
            "receiptNo": "000000",
            "payType": 1,
            "amount": "20"
        }
    ]
}

// createContract(postData);

const receipt = (contractId)=> {
    postData.contractId = contractId;
    return createContract(postData);
}

module.exports = {
    receipt
}

